package xcmg.device.dao.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.PriMaterialsDO;
import xcmg.device.service.vo.ImportReplaceVO;
import xcmg.device.service.vo.basic.MaterialsSearchVO;
import xcmg.device.service.vo.basic.MaterialsStorageVO;
import xcmg.device.service.vo.basic.MaterialsSupplierVO;
import xcmg.device.service.vo.basic.MaterialsVO;
import xcmg.device.service.vo.warehouse.SafeInventoryVO;

import java.math.BigDecimal;
import java.util.List;
/**
 * Created by GYJ on 2017-12-22.
 */
@Mapper
public interface PriMaterialsMapper {
    /**
     * insert materials
     *
     * @param record
     * @return int
     */
    int insert(PriMaterialsDO record);
    /**
     * update materials by materialsId
     *
     * @param record
     * @return int
     */
    int update(PriMaterialsDO record);
    /**
     * fetch data by condition
     *
     * @param model
     * @return List<MaterialsVO>
     */
    List<MaterialsVO> list(MaterialsSearchVO model);


    List<MaterialsVO> listByFilter(MaterialsSearchVO model);

    List<MaterialsVO> listForExport(MaterialsSearchVO model);

    List<MaterialsVO> exportList(MaterialsSearchVO model);
    /**
     * Statistics existing data by materialsNo
     *
     * @param materialsNo
     * @return int
     */
    int count(@Param("materialsNo") String materialsNo,@Param("orgId")String orgId);


    PriMaterialsDO item(@Param("materialsId")String materialsId);

    PriMaterialsDO itemByNo(@Param("materialsNo") String materialsNo,@Param("orgId") String orgId);

    PriMaterialsDO itemByNoAndArr(@Param("materialsNo") String materialsNo,@Param("orgId") String orgId, @Param("arrFactory") String arrFactory);

    List<PriMaterialsDO> selectByMaterialsNos(@Param("materailsNos") List<String> materailsNos,@Param("orgId") String orgId);
    
    PriMaterialsDO itemOemByNo(@Param("materialsNo") String materialsNo,@Param("purchaseOrgId") String purchaseOrgId);
    
    Integer getOemMaterialsCount(@Param("materialsNo") String materialsNo, @Param("orgId") String orgId, @Param("createOrgId") String createOrgId);

    PriMaterialsDO itemByNoOnly(@Param("materialsNo") String materialsNo);

    String getIdByNo(@Param("materialsNo") String materialsNo,@Param("orgId") String orgId);

    int remove(@Param("materialsId")String materialsId,@Param("updateId")String updateId);

    List<MaterialsStorageVO> materialStorage(MaterialsStorageVO recod);

    int materialStorageCount(MaterialsStorageVO recod);

    List<MaterialsVO>  amountList();

    List<MaterialsVO> listForOut(MaterialsVO model);

    Integer listCount(MaterialsSearchVO model);

    int updateSafeInventory(@Param("materialsId")String materialsId, @Param("safeAmount")BigDecimal safeAmount, @Param("maxAmount")BigDecimal maxAmount);

    int batchUpdateSafeInventory(@Param("list")List<SafeInventoryVO> list, @Param("orgId")String orgId);

    MaterialsVO selectMinimumBuy(@Param("createOrgId")String createOrgId, @Param("materialsNo")String materialsNo);

    int replaceUpdate(ImportReplaceVO entity);

    String findCustomMaterialsNo(@Param("materialsNo") String materialsNo, @Param("orgId") String orgId);

    int updateGroupPur(@Param("materialsId") String materialsId, @Param("isGroupPur") int isGroupPur);

    PriMaterialsDO itemByNoOrgId(@Param("materialsNo") String materialsNo,@Param("orgId") String orgId);

    int clearReplaceMaterialsByNoOrgId(@Param("materialsNo") String materialsNo,@Param("orgId") String orgId);

    BigDecimal getGuidePrice(@Param("materialsNo") String materialsNo,@Param("orgId") String orgId);

    List<PriMaterialsDO> listByNo(@Param("materialsNo") String materialsNo,@Param("supplierOrgId") String supplierOrgId);

    List<PriMaterialsDO> listByNoAndOrgId(@Param("materialsNo") String materialsNo, @Param("orgId") String orgId);

    /**
     * 同步更新代理商图片
     * @param record
     * @return int
     */
    int sysnUpdateImage(PriMaterialsDO record);
    
    // List<PriMaterialsDO> getOemPricePlans(@Param("oemOrgId") String oemOrgId, @Param("orgId") String orgId);
    
    PriMaterialsDO getInfoByMaterialsNo(@Param("materialsNo") String materialsNo, @Param("orgId") String orgId);

    List<MaterialsVO> listByMaterialsNos(MaterialsSearchVO model);

    BigDecimal getMaxPrice(MaterialsSearchVO model);

    List<String> listByPage(String orgId);
    
    int updateParityPrice(@Param("materialsNo") String materialsNo, @Param("orgId") String orgId, @Param("parityPrice") BigDecimal parityPrice);
    
    int deleteByMaterialId(String materialsId);
    
    int mergeMaterialInfo(PriMaterialsDO materialsDO);
    
    int updatePrice(@Param("price") BigDecimal price, @Param("materialsNo") String materialsNo, @Param("orgId") String orgId);

    int addOrUpdateGps(PriMaterialsDO priMaterialsDO);

    int batchSaveGps(@Param("list") List<PriMaterialsDO> item);

    List<PriMaterialsDO> queryG1G2Materials(@Param("list") List<PriMaterialsDO> item,@Param("fOrgIds") List<String> fOrgIds);

    List<MaterialsSupplierVO> querySupplierList(@Param("wrap") MaterialsSupplierVO v);

    List<MaterialsVO> querySupplierMaterials(MaterialsSearchVO filters);

    List<String> suplierFactoryIds(@Param("factoryIdLike") String factoryIdLike,@Param("orgId") String orgId);
}
